<template>
  <div class="LoginView">
    <el-card class="loginForm">
      <el-form ref="form" :model="form" label-width="40px">
        <el-form-item label="账号">
          <el-input v-model="form.account" placeholder="请输入账号"></el-input>
        </el-form-item>
        <el-form-item label="密码">
          <el-input
            v-model="form.pwd"
            placeholder="请输入密码"
            type="password"
            show-password
          ></el-input>
        </el-form-item>
        <el-form-item>
          <el-button type="primary" @click="onSubmit">立即登录</el-button>
          <el-button>取消</el-button>
        </el-form-item>
      </el-form>
    </el-card>
  </div>
</template>

<script>
import { login } from "@/util/model/user";
export default {
  data() {
    return {
      form: {
        account: "",
        pwd: "",
      },
    };
  },
  methods: {
    async onSubmit() {
      // this.$http.get('login',{})
      const res = await login(this.form);
      console.log(res, "denlgu result");
      this.$store.commit("login", res.data.token);
      if (res.code == 200) {
        this.$message.success("登录成功");
        this.$router.push({ name: "index" });
      } else {
        this.$message.error(res.msg);
      }
    },
  },
};
</script>
<style scoped lang="scss">
.LoginView {
  // background: url(https://pic2.zhimg.com/v2-0dd8d43103ba47961c96b2a2782b3733_r.jpg?source=1940ef5c);
  // background: rgba($color: #000000, $alpha: .2);
  position: absolute;
  width: 100%;
  height: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
  .loginForm {
    background: Transparent;
    width: 400px;
  }
}
</style>